package com.hxh.common.unification;

import com.hxh.common.enumerate.ResultEnum;
import io.swagger.annotations.ApiModelProperty;

/**
 * @Author: hxh
 * @Date: 2023/3/2
 */
public class ResultOutcome<T> {
    @ApiModelProperty("结果状态码")
    private Integer code;

    @ApiModelProperty("结果消息")
    private String message;

    @ApiModelProperty("结果返回数据")
    private T date;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getDate() {
        return date;
    }

    public void setDate(T date) {
        this.date = date;
    }

    private ResultOutcome(Integer code, String message, T date) {
        this.code = code;
        this.message = message;
        this.date = date;
    }

    private ResultOutcome() {
    }

    public static <T> ResultOutcome<T> successResult(T date) {
        ResultOutcome<T> result = new ResultOutcome<>();
        result.setCode(ResultEnum.SUCCESS.code());
        result.setDate(date);
        result.setMessage("success");
        return result;
    }
    public static <T> ResultOutcome<T> successResult() {
        ResultOutcome<T> result = new ResultOutcome<>();
        result.setCode(ResultEnum.SUCCESS.code());
        result.setMessage("success");
        return result;
    }
    public static <T> ResultOutcome<T> successResult(String message,T data) {
        ResultOutcome<T> result = new ResultOutcome<>();
        result.setCode(ResultEnum.SUCCESS.code());
        result.setMessage(message);
        result.setDate(data);
        return result;
    }


    public static <T> ResultOutcome<T> fileResult(String message) {
        ResultOutcome<T> result = new ResultOutcome<>();
        result.setCode(ResultEnum.FAIL.code());
        result.setMessage(message);
        return result;
    }


}
